﻿using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestDot : MonoBehaviour {

    public GameObject dotRoot;
	void Start () {
        CreateDotTween(dotRoot);

    }
	
	// Update is called once per frame
	void Update () {
		
	}
    void CreateDotTween(GameObject go)
    {
        Renderer meRenderer = go.transform.GetComponent<Renderer>();
        Sequence tSeq = DOTween.Sequence();
        Transform tf = go.transform;
        Renderer[] allRenderer = tf.GetComponentsInChildren<Renderer>();
        Tween t = null;
        for (int i = 0; i < allRenderer.Length; i++)
        {
            t = allRenderer[i].material.DOColor(Color.red, 1f);
            t.SetEase(Ease.InOutSine);
            tSeq.Insert(0, t);
        }
        if (meRenderer != null)
        {
            t = meRenderer.material.DOColor(Color.red, 1f);
            t.SetEase(Ease.InOutSine);
            tSeq.Insert(0, t);
        }
        tSeq.SetLoops(-1, LoopType.Yoyo);
    }
}
